package com.boc.langxiang.ui.adapter.adm;

import android.content.Context;
import android.widget.ImageView;

import com.boc.langxiang.R;
import com.boc.langxiang.entity.response.AdmEntity;
import com.boc.langxiang.entity.response.PhotoEntity;
import com.boc.langxiang.manager.PicassoImageLoader;
import com.boc.langxiang.util.StringUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * CreateTime: 2016-06-17上午9:23
 * Author: wjkjinke00@126.com
 * Description:
 */
public class AdmAdapter extends BaseQuickAdapter<AdmEntity> {

    public AdmAdapter(Context context, List<AdmEntity> data) {
        super(R.layout.item_adm, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AdmEntity item) {
        helper.setText(R.id.name, StringUtil.getValue(item.getNickname()))
                .setText(R.id.job, StringUtil.getValue(item.getZhiwu()));
        PhotoEntity photo = item.getPhoto();
        if (photo != null) {
            String url = photo.getUrl();
            PicassoImageLoader.getInstance().displayUrlImage(mContext, url, (ImageView) helper.getView(R.id.head));
        } else {
            PicassoImageLoader.getInstance().displayUrlImage(mContext, null, (ImageView) helper.getView(R.id.head));
        }
    }

}
